﻿using InputHandlers.KeyboardHandling;
using NUnit.Framework;
using System.Windows.Forms;

namespace CryptoQrUtilities.UnitTests
{
    [TestFixture]
    public class SpecialKeysExpectationManagerTests
    {
        [Test]
        public void SpecialKeyExpectationBasicTest()
        {
            var manager = new ExtendedKeysExpectationManager(Keys.Alt | Keys.Control | Keys.Shift);

            var result = manager.UpdateAndGetExtendedKeys(Keys.A, true);
            Assert.AreEqual(Keys.None, result, "1. Pressed A.");

            result = manager.UpdateAndGetExtendedKeys(Keys.Alt, true);
            Assert.AreEqual(Keys.Alt, result, "2. Pressed Alt.");

            result = manager.UpdateAndGetExtendedKeys(Keys.Control, true);
            Assert.AreEqual(Keys.Alt | Keys.Control, result, "3. Pressed Control.");

            result = manager.UpdateAndGetExtendedKeys(Keys.Shift, true);
            Assert.AreEqual(Keys.Alt | Keys.Control | Keys.Shift, result, "4. Pressed Shift.");

            result = manager.UpdateAndGetExtendedKeys(Keys.A, false);
            Assert.AreEqual(Keys.Alt | Keys.Control | Keys.Shift, result, "5. Released A.");

            result = manager.UpdateAndGetExtendedKeys(Keys.Alt, false);
            Assert.AreEqual(Keys.Control | Keys.Shift, result, "6. Released Alt.");

            result = manager.UpdateAndGetExtendedKeys(Keys.Control, false);
            Assert.AreEqual(Keys.Shift, result, "7. Released Control.");

            result = manager.UpdateAndGetExtendedKeys(Keys.Shift, false);
            Assert.AreEqual(Keys.None, result, "8. Released Shift.");
        }
    }
}

